﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cmsservice.Common.Memcached;
using cmsservice.DAL.Hibernate;

namespace cmsservice.BLL
{
    public class BBSKeyValueBLL
    {
        public string GetBBSValue(string key)
        {
            if(string.IsNullOrEmpty(key))
            {
                return "{}";
            }
            string ckey="BBSKeyValueBLL.GetBBSValue."+key;
            News2CacheTools cache = new News2CacheTools();
            var value = cache.Get<string>(ckey);
            if (string.IsNullOrEmpty(value))
            {
                BBSKeyValueDAL dal = new BBSKeyValueDAL();
                var s = dal.GetObjByKey(key);
                if (s != null)
                {
                    value = s.Value;
                    cache.Add(ckey, value, 1, 0, 0);
                }
            }
            return value;
        }
    }
}
